/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tbv_bitacora_rutaDAOImpl implements orm.dao.Tbv_bitacora_rutaDAO {
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByORMID(int bi_id_bitacora) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_rutaByORMID(session, bi_id_bitacora);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta getTbv_bitacora_rutaByORMID(int bi_id_bitacora) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_rutaByORMID(session, bi_id_bitacora);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByORMID(int bi_id_bitacora, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_rutaByORMID(session, bi_id_bitacora, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta getTbv_bitacora_rutaByORMID(int bi_id_bitacora, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_rutaByORMID(session, bi_id_bitacora, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByORMID(PersistentSession session, int bi_id_bitacora) throws PersistentException {
		try {
			return (Tbv_bitacora_ruta) session.load(orm.Tbv_bitacora_ruta.class, new Integer(bi_id_bitacora));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta getTbv_bitacora_rutaByORMID(PersistentSession session, int bi_id_bitacora) throws PersistentException {
		try {
			return (Tbv_bitacora_ruta) session.get(orm.Tbv_bitacora_ruta.class, new Integer(bi_id_bitacora));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByORMID(PersistentSession session, int bi_id_bitacora, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_ruta) session.load(orm.Tbv_bitacora_ruta.class, new Integer(bi_id_bitacora), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta getTbv_bitacora_rutaByORMID(PersistentSession session, int bi_id_bitacora, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_ruta) session.get(orm.Tbv_bitacora_ruta.class, new Integer(bi_id_bitacora), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta[] listTbv_bitacora_rutaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_rutaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta[] listTbv_bitacora_rutaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_rutaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta[] listTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_ruta as Tbv_bitacora_ruta");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tbv_bitacora_ruta[]) list.toArray(new Tbv_bitacora_ruta[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta[] listTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_ruta as Tbv_bitacora_ruta");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tbv_bitacora_ruta[]) list.toArray(new Tbv_bitacora_ruta[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_rutaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_rutaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tbv_bitacora_ruta[] tbv_bitacora_rutas = listTbv_bitacora_rutaByQuery(session, condition, orderBy);
		if (tbv_bitacora_rutas != null && tbv_bitacora_rutas.length > 0)
			return tbv_bitacora_rutas[0];
		else
			return null;
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tbv_bitacora_ruta[] tbv_bitacora_rutas = listTbv_bitacora_rutaByQuery(session, condition, orderBy, lockMode);
		if (tbv_bitacora_rutas != null && tbv_bitacora_rutas.length > 0)
			return tbv_bitacora_rutas[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTbv_bitacora_rutaByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_rutaByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_rutaByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_rutaByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_ruta as Tbv_bitacora_ruta");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_rutaByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_ruta as Tbv_bitacora_ruta");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta createTbv_bitacora_ruta() {
		return new orm.Tbv_bitacora_ruta();
	}
	
	public boolean save(orm.Tbv_bitacora_ruta tbv_bitacora_ruta) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().saveObject(tbv_bitacora_ruta);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tbv_bitacora_ruta tbv_bitacora_ruta) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().deleteObject(tbv_bitacora_ruta);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_ruta tbv_bitacora_ruta)throws PersistentException {
		try {
			if(tbv_bitacora_ruta.getTbv_ruta_programadarp_id_ruta_programada() != null) {
				tbv_bitacora_ruta.getTbv_ruta_programadarp_id_ruta_programada().tbv_bitacora_ruta.remove(tbv_bitacora_ruta);
			}
			
			return delete(tbv_bitacora_ruta);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_ruta tbv_bitacora_ruta, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tbv_bitacora_ruta.getTbv_ruta_programadarp_id_ruta_programada() != null) {
				tbv_bitacora_ruta.getTbv_ruta_programadarp_id_ruta_programada().tbv_bitacora_ruta.remove(tbv_bitacora_ruta);
			}
			
			try {
				session.delete(tbv_bitacora_ruta);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tbv_bitacora_ruta tbv_bitacora_ruta) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().refresh(tbv_bitacora_ruta);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tbv_bitacora_ruta tbv_bitacora_ruta) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().evict(tbv_bitacora_ruta);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_ruta loadTbv_bitacora_rutaByCriteria(Tbv_bitacora_rutaCriteria tbv_bitacora_rutaCriteria) {
		Tbv_bitacora_ruta[] tbv_bitacora_rutas = listTbv_bitacora_rutaByCriteria(tbv_bitacora_rutaCriteria);
		if(tbv_bitacora_rutas == null || tbv_bitacora_rutas.length == 0) {
			return null;
		}
		return tbv_bitacora_rutas[0];
	}
	
	public Tbv_bitacora_ruta[] listTbv_bitacora_rutaByCriteria(Tbv_bitacora_rutaCriteria tbv_bitacora_rutaCriteria) {
		return tbv_bitacora_rutaCriteria.listTbv_bitacora_ruta();
	}
}
